﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZyGames.DZPocker.Model;
using ZyGames.DZPocker.Tools;
using ZyGames.Framework.Cache.Generic;
using ZyGames.Framework.Game.Cache;

namespace ZyGames.DZPocker.Bll.Logic
{
	public class GameTalkingTable
	{
		private static GameTalkingTable _instance;
		private CacheList<TalkingTable> talkTableCache;

		static GameTalkingTable()
		{
			_instance = new GameTalkingTable();
		}

		private GameTalkingTable()
		{
			this.talkTableCache = new CacheList<TalkingTable>();
		}

		public static GameTalkingTable Current
		{
			get { return _instance; }
		}

		public bool Add(TalkingTable table)
		{
			if (talkTableCache.Contains(table))
			{
				Tool.WriteWarmingLine("已经包含该群聊：id:" + table.ID);
				return false;
			}
			talkTableCache.Add(table);
			return true;
		}

		public bool Delete(TalkingTable table)
		{
			if (talkTableCache.Contains(table))
				return false;
			return talkTableCache.Remove(table);
		}

		public TalkingTable Find(int tableId)
		{
			return talkTableCache.Find(i => i.ID == tableId);
		}
	}
}
